package com.zjuh.goodboy.store.jdbc;

import java.sql.Connection;

import javax.sql.DataSource;

import org.springframework.context.ApplicationContext;
import org.springframework.jdbc.core.support.JdbcDaoSupport;

import com.zjuh.goodboy.awires.AppContextAwire;
import com.zjuh.goodboy.context.AppContext;

public class BaseJdbcDaoSupport extends JdbcDaoSupport implements AppContextAwire {

	protected AppContext appContext;
	
	@Override
	public final void setAppContext(AppContext appContext) {
		this.appContext = appContext;
		ApplicationContext springContext = (ApplicationContext)appContext.getObject("springContext");
		this.setDataSource((DataSource)springContext.getBean("dataSource"));
	}
	
	public void closeConnection(Connection conn) {
		this.releaseConnection(conn);
	}

}
